# 现在要根据算法来枚举这样的字符串？？？？
import random,time

def pre_set(name:str):
    digits_ = [i for i in name if i.isdigit()]
    letters_ = [i for i in name if i.isalpha()]
    return [''.join(letters_),''.join(digits_)]


def get_numeric(object_d:list):
    res = []
    l_s = object_d[0]
    d_s = object_d[1]

    # 将字母数值化
    letter_list = []
    for i in l_s:
        letter_list.append(ord(i)-96)
    # 计算数字与其他字符的累加和
    digit_sum = 0
    for i in d_s:
        digit_sum += int(i)
    # 返回结果
    res.append(letter_list)
    res.append(digit_sum)
    return res


# def matrix_(object_d:list,name:str):
#     letter_vs = object_d[0]
#     letter_sum = sum(object_d[0])
#     number_sum = object_d[1]
#     # 这是B
#     total_sum = letter_sum+number_sum
#     # 这是C
#     magic_constant = len(name)*39
#     # 哈希值
#     if letter_sum == 0:
#         hash_ = number_sum*17
#     else:
#         hash_ = letter_vs[0]*(1 or (len(letter_vs)-1))
#     # 返回结果
#     res = hash_+total_sum*magic_constant
#     return res


def matrix_(object_d:list, name:str):
    letter_vs = object_d[0]
    letter_sum = sum(object_d[0])
    number_sum = object_d[1]
    
    # 这是B - 总数值和
    total_sum = letter_sum + number_sum
    
    # 这是C - 魔法常数
    magic_constant = len(name) * 39
    
    # 哈希值计算（修正部分）
    if len(letter_vs) == 0:
        # 如果没有字母，使用数字和乘以13
        hash_ = number_sum * 13
    else:
        # 如果有字母，使用第一个字母值乘以最后一个字母值（如果存在）
        last_letter = letter_vs[-1] if len(letter_vs) > 1 else 1
        hash_ = letter_vs[0] * last_letter
    
    # 返回结果
    res = (total_sum * magic_constant + hash_) % 101
    if res < 0:
        return res + 101
    else:
        return res
    

def get_percent(name:str):
    list_1 = pre_set(name)
    list_2 = get_numeric(list_1)
    res = matrix_(list_2,name)%101
    if res<0:
        return res+101
    else:
        return res


if __name__ == "__main__":
    # 使用while 循环生成无穷多解
    print("长度为4的解")
    while 1:
        for i in range(1,1000000):
            # 构建name字符串
            s = ""

            # 种子字符串
            seed_ = "abcdefghijklmnopqrstuvwxyz0123456789"
            
            # 使用for循环构建字符串
            for i in range(4):
                s+=random.choice(list(seed_))
            
            # 计算结果
            if get_percent(s) == 100:
                print(s)
                break
        time.sleep(3)


# 几乎很成功的一次简单逆向工程
# 虽然很简单但是说明我的基础知识部分还是可以的
# 至少我不是废物

            